package Nisha.Threads;

class printNumbers implements Runnable
{

	private volatile int count =0;
	
	public int getCount()
	{
		return count;
	}
	
	public synchronized void  setCount()
	{
		count = count+1;
	}
	
	
	@Override
	public void run() {
		
		synchronized(this)
		{
			try {
				this.wait();
				this.setCount();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			System.out.println(this.getCount());
		}
		this.notifyAll();
		
	}
	
}

public class printNumbersBy10Threads {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		printNumbers p =new printNumbers();
		Thread t1 = new Thread(p);
		Thread t2 = new Thread(p);
		Thread t3 = new Thread(p);
		Thread t4 = new Thread(p);
		Thread t5 = new Thread(p);
		Thread t6 = new Thread(p);
		Thread t7 = new Thread(p);
		Thread t8 = new Thread(p);
		Thread t9 = new Thread(p);
		Thread t10 = new Thread(p);
		t1.start();
		t2.start();
		t3.start();
		t4.start();
		t5.start();
		t6.start();
		t7.start();
		t8.start();
		t9.start();
		t10.start();

	}

}
